<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 初始值
        let i = 0
        // 定义num接收循环一次的总和
        let num = 0
        while (i <= 100) {
            num = i + num
            i++
        }
        // 输出
        document.write(`总和为${num}`)
    </script>
</body>

</html>